using System;
using System.Collections.Generic;
using Microsoft.Maps.MapControl;
using System.Globalization;

namespace Locator.Silverlight.Client.Models.ViewModels.Elements
{
    public class StoreViewModel
    {
        public Location Location
        {
            get
            {
                if (this.Latitude.HasValue && this.Longitude.HasValue)
                {
                    return new Location((double)this.Latitude.Value, (double)this.Longitude.Value);
                }
                else
                {
                    return null;
                }
            }
        }

        public string Address { get; private set; }

        public void SetAddress(string streetAddress, string city)
        {
            if (String.IsNullOrEmpty(city))
            {
                this.Address = String.Format(CultureInfo.CurrentCulture, "{0}", streetAddress);
            }
            else
            {
                this.Address = String.Format(CultureInfo.CurrentCulture, "{0}, {1}", streetAddress, city);
            }
        }

        public int Id { get; set; }

        public decimal? Latitude { get; set; }

        public decimal? Longitude { get; set; }
    }
}
